#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <cstdlib>


void handler(int signum)
{
    std::cout << "hello signal:" << signum << std::endl;
    exit(0);
}


int main()
{
    struct sigaction act,oact;
    act.sa_handler =handler;
    sigaction(SIGINT,&act,&oact);//对二号信号进行捕捉

    while(true)
    {
        std::cout << "hello world" << std::endl;
        sleep(1);
    }  
    return 0;
}